<script type="text/javascript">
	var data = "";
	var active = false;
	jQuery(function($){
		if($('body').find('#resultLoading').attr('id') != 'resultLoading'){
		$('.main').append('<div id="resultLoading" style="display:none"><div><img src="<?php echo $this->loadingImage ?>"><div><?php echo $this->loadingText ?></div></div><div class="bg"></div></div>');}
		var height = $('.main').outerHeight();
		var width = $('.main').outerWidth();
		$('.ui-slider-handle').css('cursor','pointer');
		
		$('#resultLoading').css({
			'width':'100%',
			'height':'100%',
			'position':'fixed',
			'z-index':'10000000',
			'top':'0',
			'left':'0'
		});	
		$('#resultLoading .bg').css({
			'background':'<?php echo $this->overlayColor; ?>',
			'opacity':'<?php echo $this->overlayOpacity ?>',
			'width':'100%',
			'height':'100%',
			'position':'absolute',
			'top':'0'
		});
		$('#resultLoading>div:first').css({
			'width': '100%',
			'text-align': 'center',
			'position': 'absolute',
			'left': '0',
			'top': '50%',
			'font-size':'16px',
			'z-index':'10',
			'color':'<?php echo $this->loadingTextColor ?>'
			
		});
		
		<?php if($this->ajaxLayered): ?>
        $('.block-layered-nav a').on('click', function(e){sliderAjax($(this).attr('href'));e.preventDefault();});    
        <?php endif; ?>
        
        
        <?php if($this->ajaxToolbar): ?>
        $('.toolbar a').on('click', function(e){if(!$(this).hasClass('sbToggle') && !$(this).hasClass('sbSelector') && !$(this).parent().parent().hasClass('sbOptions')){var url=$(this).attr('href');sliderAjax(url);e.preventDefault()}});
        $('.toolbar select').removeAttr('onchange');
        $('.toolbar select').on('change', function(e){var url=$(this).val();sliderAjax(url);e.preventDefault()});
        <?php endif; ?>
		
		
	});

<?php if($this->ajaxSlider || $this->ajaxLayered): ?>
/*DONOT EDIT THIS CODE*/
function sliderAjax(url) {
    if (!active) {
        active = true;
        jQuery(function($) {
            oldUrl = url;
            $('#resultLoading .bg').height('100%');
            $('#resultLoading').fadeIn(300);
            try {
                $('body').css('cursor', 'wait');
                $.ajax({
                    url: url,
                    dataType: 'json',
                    type: 'post',
                    data: data,
                    success: function(data) {
						callback();
                        if (data.viewpanel) {
                            if ($('.block-layered-nav')) {
                                $('.block-layered-nav').empty();
                                $('.block-layered-nav').append(data.viewpanel)
                            }
                        }
                        if (data.productlist) {
                            $('.col-main .category-products').empty();
                            $('.col-main .category-products').append(data.productlist)
                        }
                        var hist = url.split('?');
                        if(window.history && window.history.pushState){
							window.history.pushState('GET', data.title, url);
						}
                        $('body').find('.toolbar select').removeAttr('onchange');
                        $('#resultLoading .bg').height('100%');
                        $('#resultLoading').fadeOut(300);
                        $('body').css('cursor', 'default');
                        $('.col-main .category-products select').selectbox();
                        <?php if($this->ajaxLayered): ?>
                        $('.block-layered-nav a').on('click', function(e){sliderAjax($(this).attr('href'));e.preventDefault();});    
                        <?php endif; ?>
                        
                        
                        <?php if($this->ajaxToolbar): ?>
                        $('.toolbar a').on('click', function(e){if(!$(this).hasClass('sbToggle') && !$(this).hasClass('sbSelector') && !$(this).parent().parent().hasClass('sbOptions')){var url=$(this).attr('href');sliderAjax(url);e.preventDefault()}});
                        $('.toolbar select').removeAttr('onchange');
                        $('.toolbar select').on('change', function(e){var url=$(this).val();sliderAjax(url);e.preventDefault()});
                        <?php endif; ?>

                    }
                })
            } catch (e) {}
        });
        active = false
    }
    return false
}
<?php endif; ?> 

function callback(){
	<?php echo $this->getCallbackJs(); ?>	
}
</script>

